﻿Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Delegate Sub OnTeamViewSelected(ByVal View As Node.TreeType)

Public Class ViewTypeSelectionControl

    Public Event TeamViewSelected As OnTeamViewSelected

    Private Sub SelectServerControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        BuildDDL()
    End Sub


    Private Sub ux_ComboBoxTeamServers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ux_ComboBoxProject.SelectedIndexChanged
        My.Settings.TeamView = CStr(Me.ux_ComboBoxProject.SelectedItem)
        Me.ux_ComboBoxProject.SelectedValue = My.Settings.TeamView
        Dim SelectedTreeType As Node.TreeType = Node.TreeType.Iteration
        If Not String.IsNullOrEmpty(My.Settings.TeamView) Then
            SelectedTreeType = CType([Enum].Parse(GetType(Node.TreeType), My.Settings.TeamView), Node.TreeType)
        End If
        RaiseEvent TeamViewSelected(SelectedTreeType)
    End Sub

    Private Sub BuildDDL()
        Me.ux_ComboBoxProject.Items.Clear()
        Me.ux_ComboBoxProject.Items.AddRange([Enum].GetValues(GetType(Node.TreeType)).Cast(Of String).ToArray)
        Me.ux_ComboBoxProject.Enabled = True
    End Sub

End Class
